id/email
password
forgot password | create account
about | help | prefs
ReadingBatcode reading practice

 

 

Lambda IntroNoArgLambda3

val constVal1: () -> Int = { 4 } val constVal2: () -> Int = { 6 } fun constFunc(): Int = 8 val constVal3: () -> Int = ::constFunc // Higher-order function as a parameter fun funcNoArg3(i: Int, func: () -> Int): Int = i * func.invoke() fun main() { println(funcNoArg3(5, constVal1)) println(funcNoArg3(10, constVal2)) println(funcNoArg3(6, ::constFunc)) println(funcNoArg3(20, constVal3)) }

Click on to run the code

⬅ Back